import React, {Component} from 'react';
import {connect} from 'react-redux';
import NavLink from './NavLink';
var _ = require('lodash');
class ShopCart extends Component{

    render(){
        console.log(this.props);
        const {carts} = this.props;
        var cartsList = _.uniqWith(carts,_.isEqual);

        var output = [];
        for(let i =0;i<cartsList.length;i++){
            output.push(
                <li key={i}>名称：{cartsList[i].name} 数量：{cartsList[i].quantity}</li>
            )
        }
        return(
            <div>
            {output}
        </div>
        )       
    }
}
const getValue = (state)=>{
    return {
        carts: state.shopCartReducer.carts
    }
}
const shopCartsContext = connect(getValue)(ShopCart)
module.exports = shopCartsContext;